package demo02;

import java.util.Random;

public class MathDemo {
    public static void main(String[] args) {
        //取绝对值
        System.out.println(Math.abs(-1));//1
        //取最大值，内只能包含2个
        System.out.println(Math.max(12,34));//34
        //向下取整
        System.out.println(Math.floor(12.56));//12.0
        //向上取整
        System.out.println(Math.ceil(12.11));//13.0
        //四舍五入
        System.out.println(Math.round(12.5));//13
        int a= (int) 12.5;
        System.out.println(a);//12
        //生成随机数
        int b= (int) (Math.random()*10);//0-10之间
        System.out.println(b);
        //生成随机数
        Random random=new Random();
        int r=random.nextInt(10);
        System.out.println(r);




    }
}
